<template>
  <div class="app-container">
    <el-card class="content-edit">
      <div slot="header">路线详情</div>
      <el-form label-width="160px">
        <el-form-item label="路线名称">{{ form['name'] }}</el-form-item>
        <el-form-item label="车辆类型">{{ form['carTypeText'] }}</el-form-item>
        <el-form-item label="收费方式">{{ form['chargeType']===0?'按人数':'按车辆' }}</el-form-item>
        <el-form-item label="路线类型">{{ form['typeText'] }}</el-form-item>
        <el-form-item v-if="form['openDefault']" label="默认价格">{{ form['defaultPrice'] }}元</el-form-item>
        <el-form-item v-if="form['openWeekend']" label="周末价格">{{ form['weekendPrice'] }}元</el-form-item>
        <el-form-item v-if="form['openDate']" label="指定日期价格">{{ form['datePrice'] }}元</el-form-item>
        <el-form-item label="车型">{{ form['carTypeText'] }}</el-form-item>
        <!--<el-form-item label="荷载人数">{{ form['rideNumber'] }}</el-form-item>-->
        <el-form-item label="上车点">{{ form['pcaFromText'] }}</el-form-item>
        <el-form-item label="目的地">{{ form['pcaToText'] }}</el-form-item>
        <el-form-item>
          <router-link :to="`./edit?id=${form['id']}`">
            <el-button type="primary">编辑</el-button>
          </router-link>
          <el-button @click="$router.back()">返回</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
  export default {
    name: 'RouteAirportDetails',
    data() {
      return {
        form: {
          id: '',
          // 昵称
          name: ''
        }
      }
    },
    mounted(){
      this.form['id'] = this.$router.currentRoute.query['id'] || '';
      this.loadData();
    },
    methods: {
      // 加载用户信息
      loadData(){
        (async () => {
          const result = await this.$service.applicationGetAirportRouteDetails({id: this.form['id']});
          if (result.code === 0) {
            Object.assign(this.form, result.data || {});
          }
        })();
      }
    }
  }
</script>
